var baidu = baidu || {version: "1.3.8", author: "phoenix"};
baidu.phoenix = baidu.phoenix || {}, baidu.phoenix.array = baidu.phoenix.array || {}, baidu.phoenix.each = baidu.phoenix.array.forEach = baidu.phoenix.array.each = function (i, e, n) {
    var t, o, a, p = i.length;
    if ("function" == typeof e) for (a = 0; p > a && (o = i[a], t = e.call(n || i, o, a), t !== !1); a++) ;
    return i
}, baidu.phoenix.array.find = function (i, e) {
    var n, t, o = i.length;
    if ("function" == typeof e) for (t = 0; o > t; t++) if (n = i[t], !0 === e.call(i, n, t)) return n;
    return null
}, baidu.phoenix.array.indexOf = function (i, e, n) {
    var t = i.length;
    for (n = 0 | n, 0 > n && (n = Math.max(0, t + n)); t > n; n++) if (n in i && i[n] === e) return n;
    return -1
}, baidu.phoenix.array.remove = function (i, e) {
    for (var n = i.length; n--;) n in i && i[n] === e && i.splice(n, 1);
    return i
}, baidu.phoenix.dom = baidu.phoenix.dom || {}, baidu.phoenix.dom.g = function (i) {
    return "string" == typeof i || i instanceof String ? document.getElementById(i) : i && i.nodeName && (1 == i.nodeType || 9 == i.nodeType) ? i : null
}, baidu.phoenix.g = baidu.phoenix.G = baidu.phoenix.dom.g, baidu.phoenix.dom.getAncestorByTag = function (i, e) {
    for (i = baidu.phoenix.dom.g(i), e = e.toUpperCase(); (i = i.parentNode) && 1 == i.nodeType;) if (i.tagName == e) return i;
    return null
}, baidu.phoenix.event = baidu.phoenix.event || {}, baidu.phoenix.event.getTarget = function (i) {
    return i.target || i.srcElement
}, baidu.phoenix.event._listeners = baidu.phoenix.event._listeners || [], baidu.phoenix.lang = baidu.phoenix.lang || {}, baidu.phoenix.lang.isString = function (i) {
    return "[object String]" == Object.prototype.toString.call(i)
}, baidu.phoenix.isString = baidu.phoenix.lang.isString, baidu.phoenix.dom._g = function (i) {
    return baidu.phoenix.lang.isString(i) ? document.getElementById(i) : i
}, baidu.phoenix._g = baidu.phoenix.dom._g, baidu.phoenix.event.on = function (i, e, n) {
    e = e.replace(/^on/i, ""), i = baidu.phoenix.dom._g(i);
    var t, o = function (e) {
        n.call(i, e)
    }, a = baidu.phoenix.event._listeners, p = baidu.phoenix.event._eventFilter, d = e;
    return e = e.toLowerCase(), p && p[e] && (t = p[e](i, e, o), d = t.type, o = t.listener), i.addEventListener ? i.addEventListener(d, o, !1) : i.attachEvent && i.attachEvent("on" + d, o), a[a.length] = [i, e, n, o, d], i
}, baidu.phoenix.on = baidu.phoenix.event.on, baidu.phoenix.lang.module = function (name, module, owner) {
    var packages = name.split("."), len = packages.length - 1, packageName, i = 0;
    if (!owner) try {
        if (!new RegExp("^[a-zA-Z_$][a-zA-Z0-9_$]*$").test(packages[0])) throw"";
        owner = eval(packages[0]), i = 1
    } catch (e) {
        owner = window
    }
    for (; len > i; i++) packageName = packages[i], owner[packageName] || (owner[packageName] = {}), owner = owner[packageName];
    owner[packages[len]] || (owner[packages[len]] = module)
}, baidu.phoenix.object = baidu.phoenix.object || {}, baidu.phoenix.extend = baidu.phoenix.object.extend = function (i, e) {
    for (var n in e) e.hasOwnProperty(n) && (i[n] = e[n]);
    return i
}, baidu.phoenix.string = baidu.phoenix.string || {}, baidu.phoenix.string.decodeHTML = function (i) {
    var e = String(i).replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
    return e.replace(/&#([\d]+);/g, function (i, e) {
        return String.fromCharCode(parseInt(e, 10))
    })
}, baidu.phoenix.decodeHTML = baidu.phoenix.string.decodeHTML;
var baidu = baidu || {};
baidu.phoenix = baidu.phoenix || {}, function () {
    var i = baidu.phoenix;
    i.log = function () {
        window.console && window.console.log && console.log(arguments)
    }, i.config = {
        target: document.body,
        onAfterRender: function () {
        },
        onBindSuccess: function () {
            return !0
        },
        onBindFailure: function () {
            return !0
        },
        onAfterAuth: function () {
            return !0
        },
        tpl: "passport",
        u: document.location.href,
        html: [],
        jumpUrl: null,
        display: "page",
        act: "login",
        openInSameWin: 0
    }
}(), baidu.phoenix.lang.module("baidu.phoenix.ui", {
    popup: function (i, e, n, t) {
        var o = "";
        if (+n) {
            var a = "undefined" != typeof window.screenX ? window.screenX : window.screenLeft,
                p = "undefined" != typeof window.screenY ? window.screenY : window.screenTop,
                d = "undefined" != typeof window.outerWidth ? window.outerWidth : document.documentElement.clientWidth,
                r = "undefined" != typeof window.outerHeight ? window.outerHeight : document.documentElement.clientHeight - 22,
                u = t && +t.width || 400, s = t && +t.height || 300, c = parseInt(a + (d - u) / 2, 10),
                h = parseInt(p + (r - s) / 2.5, 10);
            "popup" == t.display && (h = 100), o = "width=" + u + ",height=" + s + ",left=" + c + ",top=" + h
        }
        return window.open(i, "bd_phoenix_" + e, o)
    }, render: function (i) {
        var e = baidu.phoenix.acc.getConfig(), n = document.createElement("ul");
        n.className = "bd-acc-list";
        var t = "";
        baidu.phoenix.each(i, function (i) {
            var n = baidu.phoenix.config.html[i], o = baidu.phoenix.array.find(e, function (e) {
                return e.type == i
            });
            t += '<li class="bd-acc-' + i + '" data-dialog="' + +o.is_dialog + '" data-acc="' + baidu.phoenix.acc.getStatusIdWithName(i) + '" data-height="' + (o.height || 0) + '" data-width="' + (o.width || 0) + '">', t += n ? n : '<img src="' + o.url + '" />', t += "</li>"
        }), n.innerHTML = t, baidu.phoenix.config.target.appendChild(n), baidu.phoenix.on(n, "click", baidu.phoenix.ui.click), baidu.phoenix.config.onAfterRender()
    }, click: function (i) {
        var e = baidu.phoenix.event.getTarget(i);
        if ("li" != e.tagName.toLowerCase() && (e = baidu.phoenix.dom.getAncestorByTag(e, "li")), e) {
            var n = e.getAttribute("data-dialog"), t = e.getAttribute("data-acc"), o = e.getAttribute("data-height"),
                a = e.getAttribute("data-width"), p = baidu.phoenix,
                d = p._SERVER_CONFIG.login + "type=" + t + "&tpl=" + p.config.tpl + "&u=" + encodeURIComponent(p.config.u) + "&display=" + p.config.display + "&act=" + p.config.act;
            if (p.config.jumpUrl) {
                var r = p.config.jumpUrl + "#display=popup";
                d = d + "&xd=" + encodeURIComponent(r), p.config.onBindFailure && "function" == typeof p.config.onBindFailure && (d += "&fire_failure=1")
            }
            p.config.subpro && (d += "&subpro=" + encodeURIComponent(p.config.subpro));
            var u = p.config.openInSameWin ? "phoenix" : t;
            baidu.phoenix.ui._active = baidu.phoenix.ui.popup(d, u, n, {width: a, height: o, display: p.config.display})
        }
    }, _active: null, close: function () {
        baidu.phoenix.ui._active && baidu.phoenix.ui._active.close(), baidu.phoenix.ui._active = null
    }
});
var BD = BD || {};
BD.XD = BD.XD || {}, BD.XD.postMessage = BD.XD.postMessage || function (i) {
    if (baidu.phoenix.ui.close(), 1 == i.success) {
        var e = decodeURIComponent(i.next);
        if (baidu.phoenix.config.onAfterAuth(e)) {
            if (i.isFirstBind = !!+i.isFirstBind, i.osType = i.os_type, !baidu.phoenix.config.onBindSuccess(e, i)) return;
            window.top.document.location.href = e
        }
    } else baidu.phoenix.config.onBindFailure && baidu.phoenix.config.onBindFailure(i)
}, !function () {
    baidu.phoenix.lang.module("baidu.phoenix.acc", {
        need_all: !1,
        _ACC_MAP: {
            1: "renren",
            2: "tsina",
            3: "baidu",
            4: "tqq",
            7: "kaixin001",
            13: "hiapk",
            14: "qunar",
            15: "qzone",
            16: "fetion",
            19: "91zs",
            42: "weixin",
            53: "tianyi",
            46: "feifan"
        },
        _ICONS_CONFIG: [{
            type: "tsina",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_sina.png",
            is_dialog: !0,
            width: 800,
            height: 669
        }, {
            type: "renren",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_renren.png",
            is_dialog: !0,
            width: 600,
            height: 356
        }, {
            type: "baidu",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_baidu.png",
            is_dialog: !1
        }, {
            type: "tqq",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_tqq.png",
            is_dialog: !0,
            width: 610,
            height: 410
        }, {
            type: "kaixin001",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_kaixin001.png",
            is_dialog: !0,
            width: 560,
            height: 376
        }, {
            type: "qzone",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_qzone.png",
            is_dialog: !0,
            width: 750,
            height: 450
        }, {
            type: "fetion",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_fetion.png",
            is_dialog: !0,
            width: 560,
            height: 351
        }, {
            type: "91zs",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_91zs.png",
            is_dialog: !0,
            width: 980,
            height: 500
        }, {
            type: "hiapk",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_hiapk.png",
            is_dialog: !0,
            width: 980,
            height: 640
        }, {
            type: "qunar",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/ico_qunar.png",
            is_dialog: !0,
            width: 850,
            height: 450
        }, {
            type: "weixin",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/icon_weixin.png",
            is_dialog: !0,
            width: 850,
            height: 450
        }, {
            type: "tianyi",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/icon_tiany.png",
            is_dialog: !0,
            width: 850,
            height: 450
        }, {
            type: "feifan",
            url: "https://passport.baidu.com/static/phoenix/scripts/jssdk/images/icon_wanda.png",
            is_dialog: !0,
            width: 850,
            height: 450
        }],
        getConfig: function () {
            return this._ICONS_CONFIG
        },
        _getAcc: function () {
            var i = baidu.phoenix._icons, e = baidu.phoenix._icons_status;
            -1 != baidu.phoenix.array.indexOf(i, "*") && (this.need_all = !0, baidu.phoenix.array.remove(i, "*"));
            var n = [];
            return baidu.phoenix.each(i, function (i) {
                1 == +e[i] && n.push(i)
            }), this.need_all && baidu.phoenix.each(this._ICONS_CONFIG, function (t) {
                t = t.type, -1 == baidu.phoenix.array.indexOf(i, t) && 1 == e[t] && n.push(t)
            }), n
        },
        _mapStatus: function () {
            var i = baidu.phoenix._icons_status;
            if (+i.err_no) return !1;
            i = i.os;
            var e = {};
            for (var n in i) {
                var t = baidu.phoenix.acc._ACC_MAP[n];
                e[t] = i[n]
            }
            return baidu.phoenix._icons_status = e, !0
        },
        getStatusIdWithName: function (i) {
            for (var e in this._ACC_MAP) if (this._ACC_MAP[e] == i) return e
        },
        init: function () {
            if (baidu.phoenix.acc._mapStatus()) {
                var i = baidu.phoenix.acc._getAcc();
                baidu.phoenix.ui.render(i)
            }
        }
    })
}();